home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / inc / exec.inc < prev    next >
Text File  |  2000-01-01  |  36KB  |  1,090 lines

  1. {
  2.     This file is part of the Free Pascal run time library.
  3.  
  4.     A file in Amiga system run time library.
  5.     Copyright (c) 1998 by Nils Sjoholm
  6.     member of the Amiga RTL development team.
  7.  
  8.     See the file COPYING.FPC, included in this distribution,
  9.     for details about the copyright.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14.  
  15.  **********************************************************************}
  16.  
  17. {
  18.     History:
  19.  
  20.     Added BOOL = Integer, some libraries need that define
  21.     (read triton, wizard)
  22.     25 Oct 1998
  23.     
  24.     Added UWORD, WORDBITS, LONGBITS, PLONGBITS,
  25.           UBYTE, PULONG, PAPTR, PLONG.
  26.       For use with MUI.
  27.     17 Jul 2000.
  28.  
  29.     nils.sjoholm@mailbox.swipnet.se
  30. }
  31.  
  32. TYPE
  33.  
  34.        STRPTR   = PChar;
  35.        ULONG    = Longint;
  36.        LONG     = longint;
  37.        APTR     = Pointer;
  38.        BPTR     = Longint;
  39.        BSTR     = Longint;
  40.        pWord    = ^Word;
  41.        pLongint = ^Longint;
  42.        pInteger = ^Integer;
  43.        BOOL     = Integer;
  44.        UWORD    = Word;
  45.        WORDBITS = Word;
  46.        LONGBITS = ULONG;
  47.        PLONGBITS = ^LONGBITS;
  48.        UBYTE    = Byte;
  49.        PULONG   = ^ULONG;
  50.        PAPTR    = ^APTR;
  51.        PLONG    = ^LONG;
  52.  
  53.  
  54. TYPE
  55.  
  56. { *  List Node Structure.  Each member in a list starts with a Node * }
  57.  
  58.   pNode = ^tNode;
  59.   tNode = Packed Record
  60.     ln_Succ,                { * Pointer to next (successor) * }
  61.     ln_Pred  : pNode;       { * Pointer to previous (predecessor) * }
  62.     ln_Type  : Byte;
  63.     ln_Pri   : Shortint;        { * Priority, for sorting * }
  64.     ln_Name  : STRPTR;      { * ID string, null terminated * }
  65.   End;  { * Note: Integer aligned * }
  66.  
  67.  
  68. { * minimal node -- no type checking possible * }
  69.  
  70.   pMinNode = ^tMinNode;
  71.   tMinNode = Packed Record
  72.     mln_Succ,
  73.     mln_Pred  : pMinNode;
  74.   End;
  75.  
  76.  
  77.  
  78. { *
  79. ** Note: Newly initialized IORequests, and software interrupt structures
  80. ** used with Cause(), should have type NT_UNKNOWN.  The OS will assign a type
  81. ** when they are first used.
  82. * }
  83.  
  84. { *----- Node Types for LN_TYPE -----* }
  85.  
  86. Const
  87.  
  88.   NT_UNKNOWN      =  0;
  89.   NT_TASK     =  1;  { * Exec task * }
  90.   NT_INTERRUPT    =  2;
  91.   NT_DEVICE   =  3;
  92.   NT_MSGPORT      =  4;
  93.   NT_MESSAGE      =  5;  { * Indicates message currently pending * }
  94.   NT_FREEMSG      =  6;
  95.   NT_REPLYMSG     =  7;  { * Message has been replied * }
  96.   NT_RESOURCE     =  8;
  97.   NT_LIBRARY      =  9;
  98.   NT_MEMORY   = 10;
  99.   NT_SOFTINT      = 11;  { * Internal flag used by SoftInits * }
  100.   NT_FONT     = 12;
  101.   NT_PROCESS      = 13;  { * AmigaDOS Process * }
  102.   NT_SEMAPHORE    = 14;
  103.   NT_SIGNALSEM    = 15;  { * signal semaphores * }
  104.   NT_BOOTNODE     = 16;
  105.   NT_KICKMEM      = 17;
  106.   NT_GRAPHICS     = 18;
  107.   NT_DEATHMESSAGE = 19;
  108.  
  109.   NT_USER     = 254;  { * User node types work down from here * }
  110.   NT_EXTENDED     = 255;
  111.  
  112. {
  113.     This file defines Exec system lists, which are used to link
  114.     various things.  Exec provides several routines to handle list
  115.     processing (defined at the bottom of this file), so you can
  116.     use these routines to save yourself the trouble of writing a list
  117.     package.
  118. }
  119.  
  120.  
  121. Type
  122.  
  123. { normal, full featured list }
  124.  
  125.     pList = ^tList;
  126.     tList = Packed record
  127.     lh_Head     : pNode;
  128.     lh_Tail     : pNode;
  129.     lh_TailPred : pNode;
  130.     lh_Type     : Byte;
  131.     l_pad       : Byte;
  132.     end;
  133.  
  134. { minimum list -- no type checking possible }
  135.  
  136.     pMinList = ^tMinList;
  137.     tMinList = Packed record
  138.     mlh_Head        : pMinNode;
  139.     mlh_Tail        : pMinNode;
  140.     mlh_TailPred    : pMinNode;
  141.     end;
  142.  
  143.  
  144.  
  145. { ********************************************************************
  146. *
  147. *  Format of the alert error number:
  148. *
  149. *    +-+-------------+----------------+--------------------------------+
  150. *    |D|  SubSysId   |  General Error |    SubSystem Specific Error    |
  151. *    +-+-------------+----------------+--------------------------------+
  152. *     1    7 bits          8 bits                  16 bits
  153. *
  154. *                    D:  DeadEnd alert
  155. *             SubSysId:  indicates ROM subsystem number.
  156. *        General Error:  roughly indicates what the error was
  157. *       Specific Error:  indicates more detail
  158. *********************************************************************}
  159.  
  160. const
  161. {*********************************************************************
  162. *
  163. *  Hardware/CPU specific alerts:  They may show without the 8 at the
  164. *  front of the number.  These are CPU/68000 specific.  See 68$0
  165. *  programmer's manuals for more details.
  166. *
  167. *********************************************************************}
  168.     ACPU_BusErr     = $80000002;      { Hardware bus fault/access error }
  169.     ACPU_AddressErr = $80000003;      { Illegal address access (ie: odd) }
  170.     ACPU_InstErr    = $80000004;      { Illegal instruction }
  171.     ACPU_DivZero    = $80000005;      { Divide by zero }
  172.     ACPU_CHK        = $80000006;      { Check instruction error }
  173.     ACPU_TRAPV      = $80000007;      { TrapV instruction error }
  174.     ACPU_PrivErr    = $80000008;      { Privilege violation error }
  175.     ACPU_Trace      = $80000009;      { Trace error }
  176.     ACPU_LineA      = $8000000A;      { Line 1010 Emulator error }
  177.     ACPU_LineF      = $8000000B;      { Line 1111 Emulator error }
  178.     ACPU_Format     = $8000000E;      { Stack frame format error }
  179.     ACPU_Spurious   = $80000018;      { Spurious interrupt error }
  180.     ACPU_AutoVec1   = $80000019;      { AutoVector Level 1 interrupt error }
  181.     ACPU_AutoVec2   = $8000001A;      { AutoVector Level 2 interrupt error }
  182.     ACPU_AutoVec3   = $8000001B;      { AutoVector Level 3 interrupt error }
  183.     ACPU_AutoVec4   = $8000001C;      { AutoVector Level 4 interrupt error }
  184.     ACPU_AutoVec5   = $8000001D;      { AutoVector Level 5 interrupt error }
  185.     ACPU_AutoVec6   = $8000001E;      { AutoVector Level 6 interrupt error }
  186.     ACPU_AutoVec7   = $8000001F;      { AutoVector Level 7 interrupt error }
  187.  
  188.  
  189. { ********************************************************************
  190. *
  191. *  General Alerts
  192. *
  193. *  For example: timer.device cannot open math.library would be $05038015
  194. *
  195. *       Alert(AN_TimerDev|AG_OpenLib|AO_MathLib);
  196. *
  197. ********************************************************************}
  198.  
  199.  
  200. CONST
  201.  
  202. { ------ alert types }
  203.   AT_DeadEnd    = $80000000;
  204.   AT_Recovery   = $00000000;
  205.  
  206.  
  207. { ------ general purpose alert codes }
  208.   AG_NoMemory   = $00010000;
  209.   AG_MakeLib    = $00020000;
  210.   AG_OpenLib    = $00030000;
  211.   AG_OpenDev    = $00040000;
  212.   AG_OpenRes    = $00050000;
  213.   AG_IOError    = $00060000;
  214.   AG_NoSignal   = $00070000;
  215.   AG_BadParm    = $00080000;
  216.   AG_CloseLib   = $00090000;    { usually too many closes }
  217.   AG_CloseDev   = $000A0000;    { or a mismatched close }
  218.   AG_ProcCreate = $000B0000;    { Process creation failed }
  219.  
  220.  
  221. { ------ alert objects: }
  222.   AO_ExecLib      = $00008001;
  223.   AO_GraphicsLib  = $00008002;
  224.   AO_LayersLib    = $00008003;
  225.   AO_Intuition    = $00008004;
  226.   AO_MathLib      = $00008005;
  227.   AO_DOSLib       = $00008007;
  228.   AO_RAMLib       = $00008008;
  229.   AO_IconLib      = $00008009;
  230.   AO_ExpansionLib = $0000800A;
  231.   AO_DiskfontLib  = $0000800B;
  232.   AO_UtilityLib   = $0000800C;
  233.   AO_KeyMapLib    = $0000800D;
  234.  
  235.   AO_AudioDev     = $00008010;
  236.   AO_ConsoleDev   = $00008011;
  237.   AO_GamePortDev  = $00008012;
  238.   AO_KeyboardDev  = $00008013;
  239.   AO_TrackDiskDev = $00008014;
  240.   AO_TimerDev     = $00008015;
  241.  
  242.   AO_CIARsrc    = $00008020;
  243.   AO_DiskRsrc   = $00008021;
  244.   AO_MiscRsrc   = $00008022;
  245.  
  246.   AO_BootStrap  = $00008030;
  247.   AO_Workbench  = $00008031;
  248.   AO_DiskCopy   = $00008032;
  249.   AO_GadTools   = $00008033;
  250.   AO_Unknown    = $00008035;
  251.  
  252.  
  253.  
  254. { ********************************************************************
  255. *
  256. *   Specific Alerts:
  257. *
  258. ********************************************************************}
  259.  
  260. { ------ exec.library }
  261.  
  262.   AN_ExecLib    = $01000000;
  263.   AN_ExcptVect  = $01000001; {  68000 exception vector checksum (obs.) }
  264.   AN_BaseChkSum = $01000002; {  Execbase checksum (obs.) }
  265.   AN_LibChkSum  = $01000003; {  Library checksum failure }
  266.  
  267.   AN_MemCorrupt = $81000005; {  Corrupt memory list detected in FreeMem }
  268.   AN_IntrMem    = $81000006; {  No memory for interrupt servers }
  269.   AN_InitAPtr   = $01000007; {  InitStruct() of an APTR source (obs.) }
  270.   AN_SemCorrupt = $01000008; {  A semaphore is in an illegal state
  271.                                       at ReleaseSempahore() }
  272.   AN_FreeTwice    = $01000009; {  Freeing memory already freed }
  273.   AN_BogusExcpt   = $8100000A; {  illegal 68k exception taken (obs.) }
  274.   AN_IOUsedTwice  = $0100000B; {  Attempt to reuse active IORequest }
  275.   AN_MemoryInsane = $0100000C; {  Sanity check on memory list failed
  276.                                       during AvailMem(MEMF_LARGEST) }
  277.   AN_IOAfterClose = $0100000D; {  IO attempted on closed IORequest }
  278.   AN_StackProbe   = $0100000E; {  Stack appears to extend out of range }
  279.   AN_BadFreeAddr  = $0100000F; {  Memory header not located. [ Usually an
  280.                                   invalid address passed to FreeMem() ] }
  281.   AN_BadSemaphore = $01000010; { An attempt was made to use the old
  282.                                       message semaphores. }
  283.  
  284. { ------ graphics.library }
  285.  
  286.   AN_GraphicsLib  = $02000000;
  287.   AN_GfxNoMem     = $82010000;  {  graphics out of memory }
  288.   AN_GfxNoMemMspc = $82010001;  {  MonitorSpec alloc, no memory }
  289.   AN_LongFrame    = $82010006;  {  long frame, no memory }
  290.   AN_ShortFrame   = $82010007;  {  short frame, no memory }
  291.   AN_TextTmpRas   = $02010009;  {  text, no memory for TmpRas }
  292.   AN_BltBitMap    = $8201000A;  {  BltBitMap, no memory }
  293.   AN_RegionMemory = $8201000B;  {  regions, memory not available }
  294.   AN_MakeVPort    = $82010030;  {  MakeVPort, no memory }
  295.   AN_GfxNewError  = $0200000C;
  296.   AN_GfxFreeError = $0200000D;
  297.  
  298.   AN_GfxNoLCM     = $82011234;  {  emergency memory not available }
  299.  
  300.   AN_ObsoleteFont = $02000401;  {  unsupported font description used }
  301.  
  302. { ------ layers.library }
  303.  
  304.   AN_LayersLib    = $03000000;
  305.   AN_LayersNoMem  = $83010000;  {  layers out of memory }
  306.  
  307. { ------ intuition.library }
  308.   AN_Intuition    = $04000000;
  309.   AN_GadgetType   = $84000001;  {  unknown gadget type }
  310.   AN_BadGadget    = $04000001;  {  Recovery form of AN_GadgetType }
  311.   AN_CreatePort   = $84010002;  {  create port, no memory }
  312.   AN_ItemAlloc    = $04010003;  {  item plane alloc, no memory }
  313.   AN_SubAlloc     = $04010004;  {  sub alloc, no memory }
  314.   AN_PlaneAlloc   = $84010005;  {  plane alloc, no memory }
  315.   AN_ItemBoxTop   = $84000006;  {  item box top < RelZero }
  316.   AN_OpenScreen   = $84010007;  {  open screen, no memory }
  317.   AN_OpenScrnRast = $84010008;  {  open screen, raster alloc, no memory }
  318.   AN_SysScrnType  = $84000009;  {  open sys screen, unknown type }
  319.   AN_AddSWGadget  = $8401000A;  {  add SW gadgets, no memory }
  320.   AN_OpenWindow   = $8401000B;  {  open window, no memory }
  321.   AN_BadState     = $8400000C;  {  Bad State Return entering Intuition }
  322.   AN_BadMessage   = $8400000D;  {  Bad Message received by IDCMP }
  323.   AN_WeirdEcho    = $8400000E;  {  Weird echo causing incomprehension }
  324.   AN_NoConsole    = $8400000F;  {  couldn't open the Console Device }
  325.   AN_NoISem       = $04000010;  { Intuition skipped obtaining a sem }
  326.   AN_ISemOrder    = $04000011;  { Intuition obtained a sem in bad order }
  327.  
  328. { ------ math.library }
  329.  
  330.   AN_MathLib      = $05000000;
  331.  
  332. { ------ dos.library }
  333.  
  334.   AN_DOSLib       = $07000000;
  335.   AN_StartMem     = $07010001; {  no memory at startup }
  336.   AN_EndTask      = $07000002; {  EndTask didn't }
  337.   AN_QPktFail     = $07000003; {  Qpkt failure }
  338.   AN_AsyncPkt     = $07000004; {  Unexpected packet received }
  339.   AN_FreeVec      = $07000005; {  Freevec failed }
  340.   AN_DiskBlkSeq   = $07000006; {  Disk block sequence error }
  341.   AN_BitMap       = $07000007; {  Bitmap corrupt }
  342.   AN_KeyFree      = $07000008; {  Key already free }
  343.   AN_BadChkSum    = $07000009; {  Invalid checksum }
  344.   AN_DiskError    = $0700000A; {  Disk Error }
  345.   AN_KeyRange     = $0700000B; {  Key out of range }
  346.   AN_BadOverlay   = $0700000C; {  Bad overlay }
  347.   AN_BadInitFunc  = $0700000D; {  Invalid init packet for cli/shell }
  348.   AN_FileReclosed = $0700000E; {  A filehandle was closed more than once }
  349.  
  350. { ------ ramlib.library }
  351.  
  352.   AN_RAMLib       = $08000000;
  353.   AN_BadSegList   = $08000001;  {  no overlays in library seglists }
  354.  
  355. { ------ icon.library }
  356.  
  357.   AN_IconLib      = $09000000;
  358.  
  359. { ------ expansion.library }
  360.  
  361.   AN_ExpansionLib       = $0A000000;
  362.   AN_BadExpansionFree   = $0A000001; {  freeed free region }
  363.  
  364. { ------ diskfont.library }
  365.  
  366.   AN_DiskfontLib        = $0B000000;
  367.  
  368. { ------ audio.device }
  369.  
  370.   AN_AudioDev   = $10000000;
  371.  
  372. { ------ console.device }
  373.  
  374.   AN_ConsoleDev = $11000000;
  375.   AN_NoWindow   = $11000001;    {  Console can't open initial window }
  376.  
  377. { ------ gameport.device }
  378.  
  379.   AN_GamePortDev        = $12000000;
  380.  
  381. { ------ keyboard.device }
  382.  
  383.   AN_KeyboardDev        = $13000000;
  384.  
  385. { ------ trackdisk.device }
  386.  
  387.   AN_TrackDiskDev = $14000000;
  388.   AN_TDCalibSeek  = $14000001;  {  calibrate: seek error }
  389.   AN_TDDelay      = $14000002;  {  delay: error on timer wait }
  390.  
  391. { ------ timer.device }
  392.  
  393.   AN_TimerDev     = $15000000;
  394.   AN_TMBadReq     = $15000001; {  bad request }
  395.   AN_TMBadSupply  = $15000002; {  power supply -- no 50/60Hz ticks }
  396.  
  397. { ------ cia.resource }
  398.  
  399.   AN_CIARsrc      = $20000000;
  400.  
  401. { ------ disk.resource }
  402.  
  403.   AN_DiskRsrc   = $21000000;
  404.   AN_DRHasDisk  = $21000001;    {  get unit: already has disk }
  405.   AN_DRIntNoAct = $21000002;    {  interrupt: no active unit }
  406.  
  407. { ------ misc.resource }
  408.  
  409.   AN_MiscRsrc   = $22000000;
  410.  
  411. { ------ bootstrap }
  412.  
  413.   AN_BootStrap  = $30000000;
  414.   AN_BootError  = $30000001;    {  boot code returned an error }
  415.  
  416. { ------ Workbench }
  417.  
  418.   AN_Workbench          = $31000000;
  419.   AN_NoFonts            = $B1000001;
  420.   AN_WBBadStartupMsg1   = $31000001;
  421.   AN_WBBadStartupMsg2   = $31000002;
  422.   AN_WBBadIOMsg         = $31000003;
  423.  
  424.   AN_WBReLayoutToolMenu          = $B1010009;
  425.  
  426. { ------ DiskCopy }
  427.  
  428.   AN_DiskCopy   = $32000000;
  429.  
  430. { ------ toolkit for Intuition }
  431.  
  432.   AN_GadTools   = $33000000;
  433.  
  434. { ------ System utility library }
  435.  
  436.   AN_UtilityLib = $34000000;
  437.  
  438. { ------ For use by any application that needs it }
  439.  
  440.   AN_Unknown    = $35000000;
  441.  
  442.  
  443.  
  444. CONST
  445.  
  446.   IOERR_OPENFAIL   = -1;    {  device/unit failed to open  }
  447.   IOERR_ABORTED    = -2;    {  request terminated early [after AbortIO()]  }
  448.   IOERR_NOCMD      = -3;    {  command not supported by device  }
  449.   IOERR_BADLENGTH  = -4;    {  not a valid length (usually IO_LENGTH)  }
  450.   IOERR_BADADDRESS = -5;    {  invalid address (misaligned or bad range)  }
  451.   IOERR_UNITBUSY   = -6;    {  device opens ok, but requested unit is busy  }
  452.   IOERR_SELFTEST   = -7;    {  hardware failed self-test  }
  453.  
  454.  
  455.  
  456. type
  457.     pResident = ^tResident;
  458.     tResident = packed record
  459.     rt_MatchWord  : Word;        { Integer to match on (ILLEGAL)  }
  460.     rt_MatchTag   : pResident;    { pointer to the above        }
  461.     rt_EndSkip    : Pointer;      { address to continue scan    }
  462.     rt_Flags      : Byte;        { various tag flags           }
  463.     rt_Version    : Byte;        { release version number      }
  464.     rt_Type       : Byte;        { type of module (NT_mumble)  }
  465.     rt_Pri        : Shortint;         { initialization priority     }
  466.     rt_Name       : STRPTR;       { pointer to node name        }
  467.     rt_IdString   : STRPTR;       { pointer to ident string     }
  468.     rt_Init       : Pointer;      { pointer to init code        }
  469.     end;
  470.  
  471. const
  472.  
  473.  
  474.     RTC_MATCHWORD   = $4AFC;
  475.  
  476.     RTF_AUTOINIT    = $80;
  477.     RTF_AFTERDOS    = $04;
  478.     RTF_SINGLETASK  = $02;
  479.     RTF_COLDSTART   = $01;
  480.  
  481.  
  482. { Compatibility: }
  483.  
  484.     RTM_WHEN        = $03;
  485.     RTW_COLDSTART   = $01;
  486.     RTW_NEVER       = $00;
  487.  
  488.  
  489.  
  490. TYPE
  491.  
  492. { ****** MemChunk **************************************************** }
  493.  
  494.   pMemChunk = ^tMemChunk;
  495.   tMemChunk = Packed Record
  496.     mc_Next  : pMemChunk;       { * pointer to next chunk * }
  497.     mc_Bytes : ULONG;           { * chunk byte size     * }
  498.   End;
  499.  
  500.  
  501. { ****** MemHeader *************************************************** }
  502.  
  503.   pMemHeader = ^tMemHeader;
  504.   tMemHeader = Packed Record
  505.     mh_Node       : tNode;
  506.     mh_Attributes : Word;       { * characteristics of this region * }
  507.     mh_First      : pMemChunk;   { * first free region          * }
  508.     mh_Lower,                    { * lower memory bound         * }
  509.     mh_Upper      : Pointer;     { * upper memory bound+1       * }
  510.     mh_Free       : Ulong;       { * total number of free bytes * }
  511.   End;
  512.  
  513.  
  514. { ****** MemEntry **************************************************** }
  515.  
  516.   pMemEntry = ^tMemEntry;
  517.   tMemEntry = packed record
  518.            me_Un : record
  519.                 case longint of
  520.                    0 : ( meu_Reqs : ULONG );
  521.                    1 : ( meu_Addr : APTR );
  522.                 end;
  523.             me_Length : ULONG;
  524.          end;
  525.  
  526. { ****** MemList ***************************************************** }
  527.  
  528. { * Note: sizeof(struct MemList) includes the size of the first MemEntry! * }
  529.  
  530.   pMemList = ^tMemList;
  531.   tMemList = Packed Record
  532.     ml_Node       : tNode;
  533.     ml_NumEntries : Word;      { * number of entries in this struct * }
  534.     ml_ME         : Array [0..0] of tMemEntry;    { * the first entry * }
  535.   End;
  536.  
  537. { *----- Memory Requirement Types ---------------------------* }
  538. { *----- See the AllocMem() documentation for details--------* }
  539.  
  540. Const
  541.  
  542.    MEMF_ANY      = %000000000000000000000000;   { * Any type of memory will do * }
  543.    MEMF_PUBLIC   = %000000000000000000000001;
  544.    MEMF_CHIP     = %000000000000000000000010;
  545.    MEMF_FAST     = %000000000000000000000100;
  546.    MEMF_LOCAL    = %000000000000000100000000;
  547.    MEMF_24BITDMA = %000000000000001000000000;   { * DMAable memory within 24 bits of address * }
  548.    MEMF_KICK     = %000000000000010000000000;   { Memory that can be used for KickTags }
  549.  
  550.    MEMF_CLEAR    = %000000010000000000000000;
  551.    MEMF_LARGEST  = %000000100000000000000000;
  552.    MEMF_REVERSE  = %000001000000000000000000;
  553.    MEMF_TOTAL    = %000010000000000000000000;   { * AvailMem: return total size of memory * }
  554.    MEMF_NO_EXPUNGE = $80000000;   {AllocMem: Do not cause expunge on failure }
  555.  
  556.    MEM_BLOCKSIZE = 8;
  557.    MEM_BLOCKMASK = MEM_BLOCKSIZE-1;
  558.  
  559. Type
  560. {***** MemHandlerData *********************************************}
  561. { Note:  This structure is *READ ONLY* and only EXEC can create it!}
  562.  
  563.  pMemHandlerData = ^tMemHandlerData;
  564.  tMemHandlerData = Packed Record
  565.         memh_RequestSize,       { Requested allocation size }
  566.         memh_RequestFlags,      { Requested allocation flags }
  567.         memh_Flags  : ULONG;    { Flags (see below) }
  568.  end;
  569.  
  570. const
  571.     MEMHF_RECYCLE  = 1; { 0==First time, 1==recycle }
  572.  
  573. {***** Low Memory handler return values **************************}
  574.     MEM_DID_NOTHING = 0;     { Nothing we could do... }
  575.     MEM_ALL_DONE    = -1;    { We did all we could do }
  576.     MEM_TRY_AGAIN   = 1;     { We did some, try the allocation again }
  577.  
  578.  
  579. type
  580.     pInterrupt = ^tInterrupt;
  581.     tInterrupt = Packed record
  582.         is_Node : tNode;
  583.         is_Data : Pointer;      { Server data segment }
  584.         is_Code : Pointer;      { Server code entry }
  585.     end;
  586.  
  587.     pIntVector = ^tIntVector;
  588.     tIntVector = Packed record          { For EXEC use ONLY! }
  589.         iv_Data : Pointer;
  590.         iv_Code : Pointer;
  591.         iv_Node : pNode;
  592.     end;
  593.  
  594.     pSoftIntList = ^tSoftIntList;
  595.     tSoftIntList = Packed record        { For EXEC use ONLY! }
  596.         sh_List : tList;
  597.         sh_Pad  : Word;
  598.     end;
  599.  
  600. const
  601.     SIH_PRIMASK = $F0;
  602.  
  603. { this is a fake INT definition, used only for AddIntServer and the like }
  604.  
  605.     INTB_NMI    = 15;
  606.     INTF_NMI    = $0080;
  607.  
  608. {
  609.     Every Amiga Task has one of these Task structures associated with it.
  610.     To find yours, use FindTask(Nil).  AmigaDOS processes tack a few more
  611.     values on to the end of this structure, which is the difference between
  612.     Tasks and Processes.
  613. }
  614.  
  615. type
  616.  
  617.     pTask = ^tTask;
  618.     tTask = Packed record
  619.         tc_Node         : tNode;
  620.         tc_Flags        : Byte;
  621.         tc_State        : Byte;
  622.         tc_IDNestCnt    : Shortint;         { intr disabled nesting         }
  623.         tc_TDNestCnt    : Shortint;         { task disabled nesting         }
  624.         tc_SigAlloc     : ULONG;        { sigs allocated                }
  625.         tc_SigWait      : ULONG;        { sigs we are waiting for       }
  626.         tc_SigRecvd     : ULONG;        { sigs we have received         }
  627.         tc_SigExcept    : ULONG;        { sigs we will take excepts for }
  628.         tc_TrapAlloc    : Word;        { traps allocated               }
  629.         tc_TrapAble     : Word;        { traps enabled                 }
  630.         tc_ExceptData   : Pointer;      { points to except data         }
  631.         tc_ExceptCode   : Pointer;      { points to except code         }
  632.         tc_TrapData     : Pointer;      { points to trap data           }
  633.         tc_TrapCode     : Pointer;      { points to trap code           }
  634.         tc_SPReg        : Pointer;      { stack pointer                 }
  635.         tc_SPLower      : Pointer;      { stack lower bound             }
  636.         tc_SPUpper      : Pointer;      { stack upper bound + 2         }
  637.         tc_Switch       : Pointer;      { task losing CPU               }
  638.         tc_Launch       : Pointer;      { task getting CPU              }
  639.         tc_MemEntry     : tList;        { allocated memory              }
  640.         tc_UserData     : Pointer;      { per task data                 }
  641.     end;
  642.  
  643. {
  644.  * Stack swap structure as passed to StackSwap()
  645.  }
  646.   pStackSwapStruct = ^tStackSwapStruct;
  647.   tStackSwapStruct = Packed Record
  648.         stk_Lower       : Pointer;      { Lowest byte of stack }
  649.         stk_Upper       : ULONG;        { Upper end of stack (size + Lowest) }
  650.         stk_Pointer     : Pointer;      { Stack pointer at switch point }
  651.   end;
  652.  
  653.  
  654.  
  655. {----- Flag Bits ------------------------------------------}
  656.  
  657. const
  658.  
  659.     TB_PROCTIME         = 0;
  660.     TB_ETASK            = 3;
  661.     TB_STACKCHK         = 4;
  662.     TB_EXCEPT           = 5;
  663.     TB_SWITCH           = 6;
  664.     TB_LAUNCH           = 7;
  665.  
  666.     TF_PROCTIME         = 1;
  667.     TF_ETASK            = 8;
  668.     TF_STACKCHK         = 16;
  669.     TF_EXCEPT           = 32;
  670.     TF_SWITCH           = 64;
  671.     TF_LAUNCH           = 128;
  672.  
  673. {----- Task States ----------------------------------------}
  674.  
  675.     TS_INVALID          = 0;
  676.     TS_ADDED            = 1;
  677.     TS_RUN              = 2;
  678.     TS_READY            = 3;
  679.     TS_WAIT             = 4;
  680.     TS_EXCEPT           = 5;
  681.     TS_REMOVED          = 6;
  682.  
  683. {----- Predefined Signals -------------------------------------}
  684.  
  685.     SIGB_ABORT          = 0;
  686.     SIGB_CHILD          = 1;
  687.     SIGB_BLIT           = 4;
  688.     SIGB_SINGLE         = 4;
  689.     SIGB_INTUITION      = 5;
  690.     SIGB_DOS            = 8;
  691.  
  692.     SIGF_ABORT          = 1;
  693.     SIGF_CHILD          = 2;
  694.     SIGF_BLIT           = 16;
  695.     SIGF_SINGLE         = 16;
  696.     SIGF_INTUITION      = 32;
  697.     SIGF_DOS            = 256;
  698.  
  699.  
  700.  
  701. {
  702.     This file defines ports and messages, which are used for inter-
  703.     task communications using the routines defined toward the
  704.     bottom of this file.
  705. }
  706.  
  707. type
  708.  
  709. {****** MsgPort *****************************************************}
  710.  
  711.     pMsgPort = ^tMsgPort;
  712.     tMsgPort = Packed record
  713.     mp_Node     : tNode;
  714.     mp_Flags    : Byte;
  715.     mp_SigBit   : Byte;     { signal bit number    }
  716.     mp_SigTask  : Pointer;   { task to be signalled (TaskPtr) }
  717.     mp_MsgList  : tList;     { message linked list  }
  718.     end;
  719.  
  720. {****** Message *****************************************************}
  721.  
  722.     pMessage = ^tMessage;
  723.     tMessage = Packed record
  724.     mn_Node       : tNode;
  725.     mn_ReplyPort  : pMsgPort;   { message reply port }
  726.     mn_Length     : Word;      { message len in bytes }
  727.     end;
  728.  
  729.  
  730.  
  731. { mp_Flags: Port arrival actions (PutMsg) }
  732.  
  733. CONST
  734.  
  735.   PF_ACTION = 3;    { * Mask * }
  736.   PA_SIGNAL = 0;    { * Signal task in mp_SigTask * }
  737.   PA_SOFTINT    = 1;    { * Signal SoftInt in mp_SoftInt/mp_SigTask * }
  738.   PA_IGNORE = 2;    { * Ignore arrival * }
  739.  
  740.  
  741.         { Semaphore }
  742. type
  743.     pSemaphore = ^tSemaphore;
  744.     tSemaphore = Packed record
  745.         sm_MsgPort : tMsgPort;
  746.         sm_Bids    : Integer;
  747.     end;
  748.  
  749. {  This is the structure used to request a signal semaphore }
  750.  
  751.     pSemaphoreRequest = ^tSemaphoreRequest;
  752.     tSemaphoreRequest = Packed record
  753.         sr_Link    : tMinNode;
  754.         sr_Waiter  : pTask;
  755.     end;
  756.  
  757. { The actual semaphore itself }
  758.  
  759.     pSignalSemaphore = ^tSignalSemaphore;
  760.     tSignalSemaphore = Packed record
  761.         ss_Link         : tNode;
  762.         ss_NestCount    : Integer;
  763.         ss_WaitQueue    : tMinList;
  764.         ss_MultipleLink : tSemaphoreRequest;
  765.         ss_Owner        : pTask;
  766.         ss_QueueCount   : Integer;
  767.     end;
  768.  
  769.  
  770. {  ***** Semaphore procure message (for use in V39 Procure/Vacate *** }
  771.  
  772.  
  773.  pSemaphoreMessage = ^tSemaphoreMessage;
  774.  tSemaphoreMessage = Packed Record
  775.    ssm_Message   : tMessage;
  776.    ssm_Semaphore : pSignalSemaphore;
  777.  end;
  778.  
  779. const
  780.  SM_SHARED      = 1;
  781.  SM_EXCLUSIVE   = 0;
  782.  
  783.  
  784. CONST
  785.  
  786. { ------ Special Constants --------------------------------------- }
  787.   LIB_VECTSIZE  =  6;   {  Each library entry takes 6 bytes  }
  788.   LIB_RESERVED  =  4;   {  Exec reserves the first 4 vectors  }
  789.   LIB_BASE  = (-LIB_VECTSIZE);
  790.   LIB_USERDEF   = (LIB_BASE-(LIB_RESERVED*LIB_VECTSIZE));
  791.   LIB_NONSTD    = (LIB_USERDEF);
  792.  
  793. { ------ Standard Functions -------------------------------------- }
  794.   LIB_OPEN  =  -6;
  795.   LIB_CLOSE = -12;
  796.   LIB_EXPUNGE   = -18;
  797.   LIB_EXTFUNC   = -24;  {  for future expansion  }
  798.  
  799. TYPE
  800.  
  801. { ------ Library Base Structure ---------------------------------- }
  802. {  Also used for Devices and some Resources  }
  803.  
  804.     pLibrary = ^tLibrary;
  805.     tLibrary = packed record
  806.         lib_Node     : tNode;
  807.         lib_Flags,
  808.         lib_pad      : Byte;
  809.         lib_NegSize,            {  number of bytes before library  }
  810.         lib_PosSize,            {  number of bytes after library  }
  811.         lib_Version,            {  major  }
  812.         lib_Revision : Word;   {  minor  }
  813.         lib_IdString : STRPTR;  {  ASCII identification  }
  814.         lib_Sum      : ULONG;   {  the checksum itself  }
  815.         lib_OpenCnt  : Word;   {  number of current opens  }
  816.     end;                {  * Warning: size is not a longword multiple ! * }
  817.  
  818. CONST
  819.  
  820. {  lib_Flags bit definitions (all others are system reserved)  }
  821.  
  822.   LIBF_SUMMING = %00000001; {  we are currently checksumming  }
  823.   LIBF_CHANGED = %00000010; {  we have just changed the lib  }
  824.   LIBF_SUMUSED = %00000100; {  set if we should bother to sum  }
  825.   LIBF_DELEXP  = %00001000; {  delayed expunge  }
  826.  
  827. {
  828.     This file defines the constants and types required to use
  829.     Amiga device IO routines, which are also defined here.
  830. }
  831.  
  832.  
  833. TYPE
  834.  
  835. {***** Device *****************************************************}
  836.   pDevice = ^tDevice;
  837.   tDevice = packed record
  838.     dd_Library : tLibrary;
  839.   end;
  840.  
  841. {***** Unit *******************************************************}
  842.   pUnit = ^tUnit;
  843.   tUnit = record
  844.       unit_MsgPort : tMsgPort;     { queue for unprocessed messages }
  845.                     { instance of msgport is recommended }
  846.       unit_flags,
  847.       unit_pad     : Byte;
  848.       unit_OpenCnt : Word;       { number of active opens }
  849.   end;
  850.  
  851. Const
  852.   UNITF_ACTIVE  = %00000001;
  853.   UNITF_INTASK  = %00000010;
  854.  
  855. type
  856.  
  857.     pIORequest = ^tIORequest;
  858.     tIORequest = packed record
  859.     io_Message  : tMessage;
  860.     io_Device   : pDevice;      { device node pointer  }
  861.     io_Unit     : pUnit;        { unit (driver private)}
  862.     io_Command  : Word;        { device command }
  863.     io_Flags    : Byte;
  864.     io_Error    : Shortint;         { error or warning num }
  865.     end;
  866.  
  867.     pIOStdReq = ^tIOStdReq;
  868.     tIOStdReq = packed record
  869.     io_Message  : tMessage;
  870.     io_Device   : pDevice;      { device node pointer  }
  871.     io_Unit     : pUnit;        { unit (driver private)}
  872.     io_Command  : Word;        { device command }
  873.     io_Flags    : Byte;
  874.     io_Error    : Shortint;         { error or warning num }
  875.     io_Actual   : ULONG;        { actual number of bytes transferred }
  876.     io_Length   : ULONG;        { requested number bytes transferred}
  877.     io_Data     : Pointer;      { points to data area }
  878.     io_Offset   : ULONG;        { offset for block structured devices }
  879.     end;
  880.  
  881.  
  882. { library vector offsets for device reserved vectors }
  883.  
  884. const
  885.     DEV_BEGINIO = -30;
  886.     DEV_ABORTIO = -36;
  887.  
  888. { io_Flags defined bits }
  889.  
  890.     IOB_QUICK   = 0;
  891.     IOF_QUICK   = 1;
  892.  
  893.     CMD_INVALID = 0;
  894.     CMD_RESET   = 1;
  895.     CMD_READ    = 2;
  896.     CMD_WRITE   = 3;
  897.     CMD_UPDATE  = 4;
  898.     CMD_CLEAR   = 5;
  899.     CMD_STOP    = 6;
  900.     CMD_START   = 7;
  901.     CMD_FLUSH   = 8;
  902.  
  903.     CMD_NONSTD  = 9;
  904.  
  905.  
  906.  
  907.  
  908. {  Definition of the Exec library base structure (pointed to by location 4).
  909. ** Most fields are not to be viewed or modified by user programs.  Use
  910. ** extreme caution.
  911.  }
  912.  
  913. type
  914.  
  915. pExecBase = ^tExecBase;
  916. tExecBase = packed Record
  917.         LibNode    : tLibrary;   {  Standard library node  }
  918.  
  919. { ******* Static System Variables ******* }
  920.  
  921.         SoftVer      : Word;   {  kickstart release number (obs.)  }
  922.         LowMemChkSum : Integer;    {  checksum of 68000 trap vectors  }
  923.         ChkBase      : ULONG;   {  system base pointer complement  }
  924.         ColdCapture,            {  coldstart soft capture vector  }
  925.         CoolCapture,            {  coolstart soft capture vector  }
  926.         WarmCapture,            {  warmstart soft capture vector  }
  927.         SysStkUpper,            {  system stack base   (upper bound)  }
  928.         SysStkLower  : Pointer; {  top of system stack (lower bound)  }
  929.         MaxLocMem    : ULONG;   {  top of chip memory  }
  930.         DebugEntry,             {  global debugger entry point  }
  931.         DebugData,              {  global debugger data segment  }
  932.         AlertData,              {  alert data segment  }
  933.         MaxExtMem    : Pointer; {  top of extended mem, or null if none  }
  934.  
  935.         ChkSum       : Word;   {  for all of the above (minus 2)  }
  936.  
  937. { ***** Interrupt Related ************************************** }
  938.  
  939.         IntVects     : Array[0..15] of tIntVector;
  940.  
  941. { ***** Dynamic System Variables ************************************ }
  942.  
  943.         ThisTask     : pTask;   {  pointer to current task (readable)  }
  944.  
  945.         IdleCount,              {  idle counter  }
  946.         DispCount    : ULONG;   {  dispatch counter  }
  947.         Quantum,                {  time slice quantum  }
  948.         Elapsed,                {  current quantum ticks  }
  949.         SysFlags     : Word;   {  misc internal system flags  }
  950.         IDNestCnt,              {  interrupt disable nesting count  }
  951.         TDNestCnt    : Shortint;    {  task disable nesting count  }
  952.  
  953.         AttnFlags,              {  special attention flags (readable)  }
  954.         AttnResched  : Word;   {  rescheduling attention  }
  955.         ResModules,             {  resident module array pointer  }
  956.         TaskTrapCode,
  957.         TaskExceptCode,
  958.         TaskExitCode : Pointer;
  959.         TaskSigAlloc : ULONG;
  960.         TaskTrapAlloc: Word;
  961.  
  962.  
  963. { ***** System Lists (private!) ******************************* }
  964.  
  965.         MemList,
  966.         ResourceList,
  967.         DeviceList,
  968.         IntrList,
  969.         LibList,
  970.         PortList,
  971.         TaskReady,
  972.         TaskWait     : tList;
  973.  
  974.         SoftInts     : Array[0..4] of tSoftIntList;
  975.  
  976. { ***** Other Globals ****************************************** }
  977.  
  978.         LastAlert    : Array[0..3] of LONG;
  979.  
  980.         {  these next two variables are provided to allow
  981.         ** system developers to have a rough idea of the
  982.         ** period of two externally controlled signals --
  983.         ** the time between vertical blank interrupts and the
  984.         ** external line rate (which is counted by CIA A's
  985.         ** "time of day" clock).  In general these values
  986.         ** will be 50 or 60, and may or may not track each
  987.         ** other.  These values replace the obsolete AFB_PAL
  988.         ** and AFB_50HZ flags.
  989.          }
  990.  
  991.         VBlankFrequency,                {  (readable)  }
  992.         PowerSupplyFrequency : Byte;   {  (readable)  }
  993.  
  994.         SemaphoreList    : tList;
  995.  
  996.         {  these next two are to be able to kickstart into user ram.
  997.         ** KickMemPtr holds a singly linked list of MemLists which
  998.         ** will be removed from the memory list via AllocAbs.  If
  999.         ** all the AllocAbs's succeeded, then the KickTagPtr will
  1000.         ** be added to the rom tag list.
  1001.          }
  1002.  
  1003.         KickMemPtr,             {  ptr to queue of mem lists  }
  1004.         KickTagPtr,             {  ptr to rom tag queue  }
  1005.         KickCheckSum : Pointer; {  checksum for mem and tags  }
  1006.  
  1007. { ***** V36 Exec additions start here ************************************* }
  1008.  
  1009.         ex_Pad0           : Word;
  1010.         ex_Reserved0      : ULONG;
  1011.         ex_RamLibPrivate  : Pointer;
  1012.  
  1013.         {  The next ULONG contains the system "E" clock frequency,
  1014.         ** expressed in Hertz.  The E clock is used as a timebase for
  1015.         ** the Amiga's 8520 I/O chips. (E is connected to "02").
  1016.         ** Typical values are 715909 for NTSC, or 709379 for PAL.
  1017.          }
  1018.  
  1019.         ex_EClockFrequency,         {  (readable)  }
  1020.         ex_CacheControl,            {  Private to CacheControl calls  }
  1021.         ex_TaskID         : ULONG;  {  Next available task ID  }
  1022.  
  1023.         ex_Reserved1      : Array[0..4] of ULONG;
  1024.  
  1025.         ex_MMULock        : Pointer;    {  private  }
  1026.  
  1027.         ex_Reserved2      : Array[0..2] of ULONG;
  1028. {***** V39 Exec additions start here *************************************}
  1029.  
  1030.         { The following list and data element are used
  1031.          * for V39 exec's low memory handler...
  1032.          }
  1033.         ex_MemHandlers    : tMinList; { The handler list }
  1034.         ex_MemHandler     : Pointer;          { Private! handler pointer }
  1035. end;
  1036.  
  1037.  
  1038. { ***** Bit defines for AttnFlags (see above) ***************************** }
  1039.  
  1040. {   Processors and Co-processors:  }
  1041.  
  1042. CONST
  1043.  
  1044.   AFB_68010     = 0;    {  also set for 68020  }
  1045.   AFB_68020     = 1;    {  also set for 68030  }
  1046.   AFB_68030     = 2;    {  also set for 68040  }
  1047.   AFB_68040     = 3;
  1048.   AFB_68881     = 4;    {  also set for 68882  }
  1049.   AFB_68882     = 5;
  1050.   AFB_FPU40     = 6;    {  Set if 68040 FPU }
  1051.  
  1052.   AFF_68010     = %00000001;
  1053.   AFF_68020     = %00000010;
  1054.   AFF_68030     = %00000100;
  1055.   AFF_68040     = %00001000;
  1056.   AFF_68881     = %00010000;
  1057.   AFF_68882     = %00100000;
  1058.   AFF_FPU40     = %01000000;
  1059.  
  1060. {    AFB_RESERVED8 = %000100000000;  }
  1061. {    AFB_RESERVED9 = %001000000000;  }
  1062.  
  1063.  
  1064. { ***** Selected flag definitions for Cache manipulation calls ********* }
  1065.  
  1066.   CACRF_EnableI       = %0000000000000001;  { Enable instruction cache  }
  1067.   CACRF_FreezeI       = %0000000000000010;  { Freeze instruction cache  }
  1068.   CACRF_ClearI        = %0000000000001000;  { Clear instruction cache   }
  1069.   CACRF_IBE           = %0000000000010000;  { Instruction burst enable  }
  1070.   CACRF_EnableD       = %0000000100000000;  { 68030 Enable data cache   }
  1071.   CACRF_FreezeD       = %0000001000000000;  { 68030 Freeze data cache   }
  1072.   CACRF_ClearD        = %0000100000000000;  { 68030 Clear data cache    }
  1073.   CACRF_DBE           = %0001000000000000;  { 68030 Data burst enable   }
  1074.   CACRF_WriteAllocate = %0010000000000000;  { 68030 Write-Allocate mode
  1075.                                               (must always be set!)     }
  1076.   CACRF_EnableE       = 1073741824;  { Master enable for external caches }
  1077.                                      { External caches should track the }
  1078.                                      { state of the internal caches }
  1079.                                      { such that they do not cache anything }
  1080.                                      { that the internal cache turned off }
  1081.                                      { for. }
  1082.  
  1083.   CACRF_CopyBack      = $80000000;  { Master enable for copyback caches }
  1084.  
  1085.   DMA_Continue        = 2;      { Continuation flag for CachePreDMA }
  1086.   DMA_NoModify        = 4;      { Set if DMA does not update memory }
  1087.   DMA_ReadFromRAM     = 8;      { Set if DMA goes *FROM* RAM to device }
  1088.  
  1089.  
  1090.